package com.lzm.ydpt.entity;

import android.os.Parcel;
import android.os.Parcelable;

public class FilterBean implements Parcelable {

    private String filterName;
    private int filterId;
    private boolean isSelect;

    public FilterBean(String filterName, int filterId, boolean isSelect) {
        this.filterName = filterName;
        this.filterId = filterId;
        this.isSelect = isSelect;
    }

    protected FilterBean(Parcel in) {
        filterName = in.readString();
        filterId = in.readInt();
        isSelect = in.readByte() != 0;
    }

    /**
     * 重写hashCode，方便集合的操作
     */
    @Override
    public int hashCode() {
        return (this.filterId + this.filterId);
    }

    /**
     * 重写equals，只要tagid相同就默认是通对象，才认为这个对象是想等的
     */
    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof FilterBean)) {
            return false;
        }
        FilterBean tempInfo = (FilterBean) obj;
        return (this.filterId == tempInfo.filterId);
    }

    public static final Creator<FilterBean> CREATOR = new Creator<FilterBean>() {
        @Override
        public FilterBean createFromParcel(Parcel in) {
            return new FilterBean(in);
        }

        @Override
        public FilterBean[] newArray(int size) {
            return new FilterBean[size];
        }
    };

    public String getFilterName() {
        return filterName;
    }

    public void setFilterName(String filterName) {
        this.filterName = filterName;
    }

    public int getFilterId() {
        return filterId;
    }

    public void setFilterId(int filterId) {
        this.filterId = filterId;
    }

    public boolean isSelect() {
        return isSelect;
    }

    public void setSelect(boolean select) {
        isSelect = select;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(filterName);
        dest.writeInt(filterId);
        dest.writeByte((byte) (isSelect ? 1 : 0));
    }
}